package svc

import (
	"github.com/zeromicro/go-zero/core/stores/redis"
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
	"property_api/internal/config"
	"property_service/client/asset_service"
	"property_service/client/basic_service"
	"property_service/client/customize_service"
	"property_service/client/inventory_service"
)

type ServiceContext struct {
	Config           config.Config
	RedisConn        *redis.Redis
	BasicService     basic_service.BasicService
	InventoryService inventory_service.InventoryService
	AssetService     asset_service.AssetService
	CustomizeService customize_service.CustomizeService
	CheckRbac        rest.Middleware
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:           c,
		BasicService:     basic_service.NewBasicService(zrpc.MustNewClient(c.PropertyRpc)),
		InventoryService: inventory_service.NewInventoryService(zrpc.MustNewClient(c.PropertyRpc)),
		AssetService:     asset_service.NewAssetService(zrpc.MustNewClient(c.PropertyRpc)),
		CustomizeService: customize_service.NewCustomizeService(zrpc.MustNewClient(c.PropertyRpc)),
	}
}
